package com.bourse.dbfeeder;

import gnu.getopt.Getopt;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.bourse.dbfeeder.services.feeder.FeederService;
import com.bourse.dbfeeder.services.feeder.FeederType;

/**
 * Hello world!
 */
public class App {
		
	public static void main(String[] args) {
		
		Getopt g = new Getopt("dbFeeder", args, "-:HC");
		ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(	new String[] { "applicationContext.xml" });
		FeederService feederService = (FeederService)appContext.getBean("feederService");
					
		int c;	
		while ((c = g.getopt()) != -1){
			switch(c){
	          	case 'H':
	          		feederService.feedDatabase(FeederType.HISTO);
	        		break;
	          	case 'C':
	          		feederService.feedDatabase(FeederType.EURONEXT);
	        		break;	        	  	
	          	default:
	          		System.out.print("getopt() returned " + c + "\n");
	       }
		}		
	}
	
	
}
